<?php

namespace
{
    header('Content-Type: text/html; charset=utf-8');
    define('SYSPATH', __DIR__ . DIRECTORY_SEPARATOR);
    require_once \SYSPATH . 'Core/Loader.php';

    /**
     * The general configuration.
     */

    const CFG_GENERAL = 0;
    /**
     * The database configuration.
     */
    const CFG_DATABASE = 1;
    /**
     * The hooks configuration.
     */
    const CFG_HOOKS = 2;
    /**
     * The routes configuration.
     */
    const CFG_ROUTES = 3;
    /**
     * The logs configuration.
     */
    const CFG_LOGS = 4;
    /**
     * The segments configuration.
     */
    const CFG_SEGMENTS = 5;
    /**
     * The uri configuration.
     */
    const CFG_URI = 6;
    /**
     * The language configuration.
     */
    const CFG_LANG = 7;

    function config_item($name, $type = \CFG_GENERAL)
    {
        return \System\Core\Config::GetValue($type, $name);
    }

    function evald(\System\Types\String $evalution, $parameters = null)
    {
        $args = func_get_args();

        for($i = 1; $i < func_num_args(); $i++)
        {
            $_ = "_{$i}";

            $$_ = $args[$i];
        }

        eval($evalution->ToString());
    }

}

namespace System
{

    use \System\Types\Object;

    abstract class StartUp extends Object
    {

        private $eng = null;
        protected $loader = null;

        public final function __construct()
        {
            parent::__construct();

            $this->loader = Core\Loader::GetInstance();

            $this->init();

            $this->eng = Core\Engineer::SystemEngine();

            $this->log(Lib\Log::Read());

            $this->end();

            die();
        }

        abstract protected function init();

        abstract protected function end();

        /**
         * @param Core\Errors\Error $error
         */
        abstract protected function log(Array $error);

        public static function SystemPath()
        {
            return __DIR__;
        }

    }

}
